package cn.tanfp.dynamicdatasource.controller;

import cn.tanfp.dynamicdatasource.pojo.User;
import cn.tanfp.dynamicdatasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class Controller {

    @Autowired
    private UserService userService;

    @GetMapping("/users")
    public List<User> getUsers () {
        return userService.findAll();
    }

    @GetMapping("/adduser")
    public String addUser (String name) {
        userService.addUser(name);
        return "ok";
    }
}
